﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dora.Tools.Enums.AdminUser;
using Dora.Tools.Utility;

namespace Dora.Services.AdminUser.Dto.ViewDto
{
    /// <summary>
    /// 组织机构业务对象
    /// </summary>
    public class OrganizationDto
    {
        /// <summary>
        /// 组织机构Id
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 组织机构名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 简称
        /// </summary>
        public string ShortName { get; set; }
        /// <summary>
        /// 统一社会信用代码
        /// </summary>
        public string CreditCode { get; set; }

        /// <summary>
        /// 根节点Id;顶级根节点Id 2019-06-25新增字段
        /// </summary>
        public int RootId { get; set; }

        /// <summary>
        /// 级别序号
        /// </summary>
        public int LevelIdx { get; set; }

        /// <summary>
        /// 机构级别;组织机构级别 0：总（大）社，1：分社，2：门店，3：直属门店，4：直属部门。
        /// </summary>
        public int OrgLevel { get; set; }

        /// <summary>
        /// 旅行社负责人
        /// </summary>
        public string OrgHeadName { get; set; }

        /// <summary>
        /// 旅行社负责人联系电话
        /// </summary>
        public string OrgHeadPhone { get; set; }

        /// <summary>
        /// 负责人
        /// </summary>
        public string LeaderName { get; set; }

        /// <summary>
        /// 联系电话
        /// </summary>
        public string LeaderPhone { get; set; }

        /// <summary>
        /// 机构所在省份Id
        /// </summary>
        public int? ProvinceId { get; set; }

        /// <summary>
        /// 机构所在省份名称
        /// </summary>
        public string ProvinceName { get; set; }

        /// <summary>
        /// 机构所在城市Id
        /// </summary>
        public int? CityId { get; set; }

        /// <summary>
        /// 机构所在城市名称
        /// </summary>
        public string CityName { get; set; }
        /// <summary>
        /// 机构所在区(县)名称
        /// </summary>
        public string DistrictName { get; set; }
        /// <summary>
        /// 机构所在镇(乡)名称
        /// </summary>
        public string TownName { get; set; }
        /// <summary>
        /// 详细地址
        /// </summary>
        public string Address { get; set; }
        
        //public bool hasChildren { get { return Children != null && Children.Any(); } }
        /// <summary>
        /// 组织机构级别显示文本
        /// </summary>
        public string OrgLevelDisplay { get { return ((OrgLevel)OrgLevel).ToDescription(); } }
        /// <summary>
        /// 上级Id
        /// </summary>
        public int ParentId { get; set; }
        /// <summary>
        /// 上级机构名称
        /// </summary>
        public string ParentOrgName { get; set; }

        /// <summary>
        /// 上级组织机构的级别
        /// </summary>
        public int ParentOrgLevel { get; set; }

        /// <summary>
        /// 是否禁用 2019-05-14新增字段
        /// </summary>
        public short IsDisabled { get; set; }

        /// <summary>
        /// 是否冻结 2019-05-14新增字段
        /// </summary>
        public short IsFrozen { get; set; }

        /// <summary>
        /// 是否包含子机构
        /// </summary>
        public short HasSub { get; set; }

        /// <summary>
        /// 是否包可独立签约保险的分社机构
        /// </summary>
        public bool HasInsuranceSub { get; set; }

        /// <summary>
        /// 【分社】是否允许开设门店
        /// </summary>
        public int IsAllowOpenStores { get; set; }

        /// <summary>
        /// 上级机构如果是【分社】时，是否允许开设门店
        /// </summary>
        public int ParentIsAllowOpenStores { get; set; }

        /// <summary>
        /// 层级路径;从最祖宗到本级,英文逗号分隔
        /// </summary>
        public string LevelPath { get; set; }

        /// <summary>
        /// 是否叶子节点
        /// </summary>
        public bool IsLeaf { get { return HasSub == 0; } }

        /// <summary>
        /// 下级组织机构集合
        /// </summary>
        public List<OrganizationDto> children { get; set; }
    }
}
